<?php

	// +----------------------------------------------------------------------
	// | 系统设置
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\controller\ucenter\admin;

	use app\controller\admin\Common;
	use app\common\event\SystemConfig as SystemConfigEvent;
	use app\common\model\SystemConfig as SystemConfigModel;
	use think\facade\Config;

	class Setting extends Common
	{

		/**
		 * 用户中心配置
		 * @return mixed|string
		 * @author  : 微尘 <yicmf@qq.com>
		 */
		public function index()
		{
			if ($this->request->isPost()) {
				if (config('ucenter.avatar_id') != $this->request->param('ucenter.avatar_id')) {
					\app\model\ucenter\User::where('avatar_id', Config::get('ucenter.avatar_id'))->update(['avatar_id' => $this->request->param('ucenter.avatar_id')]);
				}
				$event = new SystemConfigEvent();
				$re = $event->updateValue($this->request->post(), $this->user);
				$this->_returnAuto($re, false);
			} else {
				$set = SystemConfigModel::where('status', 1)->where('group', 'ucenter')->order('sort ASC')->where('is_dev', 0)->order('sort ASC')->select();
				return SystemConfigEvent::builderView($set, '站点配置');
			}
		}
	}
